package com.shwread.android.qysw.activity;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.shwread.android.qysw10000243.R;


/**
 * @author :yqq
 * @version 创建时间：2015-5-7 上午10:34:38
 *          互动中心page 跳转的 联系人界面
 */
public class NewIntercationCenterToLinkmanActivity
        extends
		Activity
        implements
        OnClickListener
{
	private Button   backbtn;
	private ListView linkman_lv;
	private String[] names = new String[] {
	        "客户经理",
	        "白银客户群",
	        "总客户群"
	                              };
	private String[] times    = new String[] {
	        "12:00",
	        "15/2/7",
	        "15/2/6"
	                              };
	private String[] msgs        = new String[] {
	        "最近一条信息",
	        "最近一条信息",
	        "最近一条信息"
	                              };
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.new_interaction_center_to_linkman_layout);
		TextView titlename = (TextView) findViewById(R.id.common_header_name);
		titlename.setText("联系人");
		backbtn = (Button) findViewById(R.id.common_header_back);
		backbtn.setVisibility(View.VISIBLE);
		backbtn.setOnClickListener(this);
		
		linkman_lv = (ListView) findViewById(R.id.intercation_to_linkman_listview);
		MyAdapter myadapter = new MyAdapter(this);
		linkman_lv.setAdapter(myadapter);
		
	}
	
	@Override
	public void onClick(View v) {
		switch (v.getId()) {
			case R.id.common_header_back:
				finish();
				break;
			
			default:
				break;
		}
	}
	
	class MyAdapter
	        extends
	        BaseAdapter
	{
		private Context context;
		
		public MyAdapter(Context context) {
			this.context = context;
			
		}
		
		@Override
		public int getCount() {
			// TODO Auto-generated method stub
			return names.length;
		}
		
		@Override
		public Object getItem(int position) {
			// TODO Auto-generated method stub
			return names[position];
		}
		
		@Override
		public long getItemId(int position) {
			// TODO Auto-generated method stub
			return position;
		}
		
		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			ViewHolder viewHolder;
			if (convertView == null)
			{
				viewHolder = new ViewHolder();
				convertView = LayoutInflater.from(context).inflate(R.layout.new_interaction_linkman_listview_item, parent, false);
				viewHolder.headportrait_iv = (ImageView) convertView.findViewById(R.id.interaction_linkman_imageview);
				viewHolder.name_tv = (TextView) convertView.findViewById(R.id.interaction_linkman_tv_name);
				viewHolder.time_tv = (TextView) convertView.findViewById(R.id.interaction_linkman_tv_time);
				viewHolder.msg_tv = (TextView) convertView.findViewById(R.id.interaction_linkman_tv_msg);
				viewHolder.time_tv.setVisibility(View.GONE);
				convertView.setTag(viewHolder);
			}
			else
			{
				viewHolder = (ViewHolder) convertView.getTag();
			}
			//填充数据
			viewHolder.name_tv.setText(names[position]);
			viewHolder.time_tv.setText(times[position]);
			viewHolder.msg_tv.setText(msgs[position]);
			
			return convertView;
		}
		
	}
	
	class ViewHolder
	{
		private ImageView headportrait_iv;
		private TextView  name_tv;
		private TextView  time_tv;
		private TextView  msg_tv;
	}
}
